/**
 * @Date 2023-02-21 09:42:02
 * @Remark
 */

// lib
// config
// script & methods & public
// import logUtils from "utils/logUtils";
// http
// import { open, bag, isOkRes } from "public/http/api";
// service
import {
  simpleListService,
  simpleObjectService,
  simplePageService,
  simpleResService,
} from "public/service/simple.service";
// api
import {
  API_ADMIN_ADD,
  ReqAddAdmin,
  ReqAdminPage,
  API_ADMIN_PAGE,
  API_ADMIN_UPDATE,
  ReqAdminUpdate,
  API_ADMIN_DEL,
  API_ADMIN_DETAIL,
  ReqResetPwd,
  API_ADMIN_RESET_PWD,
  ReqEditAdminState,
  API_ADMIN_CHANGE_STATE,
  ReqEditAdminRole,
  API_ADMIN_EDIT_ROLE,
  ReqGetAdminRole,
  API_ADMIN_ROLE_LIST,
} from "./api";
// interface
// 其它

// 管理账户分页
export async function getAdminPageService(params: ReqAdminPage) {
  return simplePageService<ReqAdminPage, AdminItemDto>(API_ADMIN_PAGE, params);
}

// 管理账户搜索
export async function searchAdminService(params: ReqAdminPage) {
  return simplePageService<ReqAdminPage, AdminItemDto>(API_ADMIN_PAGE, params);
}

// 管理账户详情
export async function getAdminDetailService(id: number) {
  return simpleObjectService<ReqById, AdminItemDto>(API_ADMIN_DETAIL, {
    id,
  });
}

// 管理账户添加
export async function addAdminService(params: ReqAddAdmin) {
  return simpleResService<ReqAddAdmin>(API_ADMIN_ADD, params);
}

// 管理账户编辑
export async function updateAdminService(params: ReqAdminUpdate) {
  return simpleResService<ReqAdminUpdate>(API_ADMIN_UPDATE, params);
}

// 管理账户删除
export async function delAdminService(userId: number | string) {
  return simpleResService<any>(API_ADMIN_DEL, {
    userId,
  });
}

// 重置密码
export async function resetAdminPwdService(params: ReqResetPwd) {
  return simpleResService<ReqResetPwd>(API_ADMIN_RESET_PWD, params);
}

// 编辑管理账户状态
export async function editAdminStateService(params: ReqEditAdminState) {
  return simpleResService<ReqEditAdminState>(API_ADMIN_CHANGE_STATE, params);
}

// 编辑管理账户角色
export async function editAdminRoleService(params: ReqEditAdminRole) {
  return simpleResService<ReqEditAdminRole>(API_ADMIN_EDIT_ROLE, params);
}

// 管理账户角色列表
export async function getAdminRoleService(params: ReqGetAdminRole) {
  return simpleListService<ReqGetAdminRole, AdminItemDto>(
    API_ADMIN_ROLE_LIST,
    params,
  );
}
